<?php
/**
 * Created by PhpStorm.
 * User: geolo
 * Date: 2018/10/8
 * Time: 15:51
 */

defined('YII_RUN') or exit('Access Denied');
$urlManager = Yii::$app->urlManager;
$this->title = '文字魔方编辑';
$this->params['active_nav_group'] = 1;
?>

<div class="panel mb-3" id="app">
    <div class="panel-header"><?= $this->title ?></div>
    <div class="panel-body">
        <form class="auto-form" method="post" return="<?= $urlManager->createUrl(['mch/store/character-block']) ?>">

            <div class="form-group row">
                <div class="form-group-label col-sm-2 text-right">
                    <label class="col-form-label required">板块名称</label>
                </div>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="name" value="<?= $model->name ?>">
                </div>
            </div>
            <div class="form-group row">
                <div class="form-group-label col-sm-2 text-right">
                    <label class="col-form-label required">英文名称</label>
                </div>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="name_e" value="<?= $model->name_e ?>">
                </div>
            </div>
            <div class="form-group row">
                <div class="form-group-label col-sm-2 text-right">
                    <label class="col-form-label">跳转地址</label>
                </div>
                <div class="col-sm-8">
                    <div class="row mb-3" >
                        <div class="col-sm-5">
                            <div class="input-group page-link-input">
                                <input class="form-control link-input"
                                       readonly name="url"
                                       value="<?= $model->url ?>">
                                <span class="input-group-btn">
                                        <a class="btn btn-secondary pick-link-btn" href="javascript:"
                                           open-type="navigate,wxapp">选择链接</a>
                                </span>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
            <div class="form-group row">
                <div class="form-group-label col-sm-2 text-right">
                </div>
                <div class="col-sm-6">
                    <a class="btn btn-primary auto-form-btn" href="javascript:">保存</a>
                </div>
            </div>
        </form>
    </div>
</div>

<?php
$model_data = json_decode($model->url, true);
$pic_list = $model_data['url'];
if (empty($pic_list)) {
    $pic_list ='';
}
?>
<script>

    var app = new Vue({
        el: "#app",
        data: {
            pic_list: <?=json_encode($pic_list, JSON_UNESCAPED_UNICODE)?>,
        }
    });


    $(document).on("change", ".link-input", function () {;
        app.pic_list = $(this).val();
    });





</script>